﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; 
namespace KMS.Core
{
    public partial class ServiceBase<T>
    {
        //protected static ILog log = LogManager.GetLogger(String.Format("Service{0}", typeof(T).Name)); 
        public void Logger(string actionName, Action action,bool isShowException = false,Action<Exception> catchHandle = null, Action finallyHandle = null)
        {
            try
            {
                action();
            }
            catch (Exception ex)
            {
                if (catchHandle != null)
                {
                    catchHandle(ex);
                }
                if (isShowException)
                {
                    throw ex;
                }
               
            }
            finally
            {
                if (finallyHandle != null)
                {
                    finallyHandle();
                }

            }
        }
    }
}
